﻿#region Using directives
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
#endregion

namespace gpsMe.Classes
{
    /// <summary>
    /// gpsMe location axis value (latitude or longitude)
    /// </summary>
    public class gpsMeLocationAxis
    {
        #region Properties
        /// <summary>
        /// Longitude axis type
        /// </summary>
        public const bool AXIS_TYPE_LATITUDE = false;

        /// <summary>
        /// Latitude axis type
        /// </summary>
        public const bool AXIS_TYPE_LONGITUDE = true;
        #endregion

        #region Attributes
        /// <summary>
        /// Decimal dergrees value of the location axis
        /// </summary>
        private double degreesValue;

        /// <summary>
        /// Type of the location axis
        /// </summary>
        private bool axisType;

        /// <summary>
        /// Specifies if the axis type is defined
        /// </summary>
        private bool axisTypeDefined;
        #endregion

        #region Accessors
        /// <summary>
        /// Value of the location axis
        /// </summary>
        public double DegreesValue
        {
            get
            {
                return this.degreesValue;
            }
            set
            {
                this.degreesValue = value;
            }
        }

        /// <summary>
        /// Axis type of the location axis (latitude or longitude)
        /// </summary>
        public bool AxisType
        {
            get
            {
                return this.axisType;
            }
            set
            {
                this.axisType = value;
            }
        }
        
        /// <summary>
        /// Returns the value of the location axis in degrees minutes seconds
        /// </summary>
        public string DegreesMinutesSecondsValue
        {
            get
            {
                if (axisTypeDefined)
                    return DegreesToDegreesMinutesSeconds(this.degreesValue, axisType);
                else
                    return DegreesToDegreesMinutesSeconds(this.degreesValue);
            }
            set
            {
                this.degreesValue = DegreesMinutesSecondsToDegrees(value);
            }
        }
        #endregion

        #region Constructors
        /// <summary>
        /// Default constructor
        /// </summary>
        public gpsMeLocationAxis()
        {
            this.axisTypeDefined = false;
        }

        /// <summary>
        /// Constructor with param
        /// </summary>
        /// <param name="p_dValue">decimal degrees value</param>
        public gpsMeLocationAxis(double p_dValue)
        {
            this.degreesValue = p_dValue;
            this.axisTypeDefined = false;
        }
        
        /// <summary>
        /// Constructor with params
        /// </summary>
        /// <param name="p_dValue">decimal degrees value</param>
        /// <param name="p_bAxisType">axis type</param>
        public gpsMeLocationAxis(double p_dValue, bool p_bAxisType)
        {
            this.degreesValue = p_dValue;
            this.axisType = p_bAxisType;
            this.axisTypeDefined = true;
        }
        /// <summary>
        /// Constructor with param
        /// </summary>
        /// <param name="p_sValue">degrees minutes seconds value</param>
        public gpsMeLocationAxis(string p_sValue)
        {
            this.degreesValue = DegreesMinutesSecondsToDegrees(p_sValue);
            this.axisTypeDefined = true;
        }

        /// <summary>
        /// Constructor with params
        /// </summary>
        /// <param name="p_sValue">degrees minutes seconds value</param>
        /// <param name="p_bAxisType">axis type</param>
        public gpsMeLocationAxis(string p_sValue, bool p_bAxisType)
        {
            this.degreesValue = DegreesMinutesSecondsToDegrees(p_sValue);
            this.axisType = p_bAxisType;
            this.axisTypeDefined = true;
        }
        #endregion

        #region Methods / Functions / Events
        /// <summary>
        /// Converts degrees axis value to degrees minutes seconds axis value
        /// </summary>
        /// <param name="degrees">degrees of the axis value</param>
        /// <param name="p_bAxisType">latitude or longitude</param>
        /// <returns>axis value in degrees minutes seconds</returns>
        public static string DegreesToDegreesMinutesSeconds(double degrees, bool p_bAxisType)
        {
            return "coming soon";
        }

        /// <summary>
        /// Converts degrees axis value to degrees minutes seconds axis value
        /// </summary>
        /// <param name="degrees">degrees of the axis value</param>
        /// <returns>axis value in degrees minutes seconds</returns>
        public static string DegreesToDegreesMinutesSeconds(double degrees)
        {
            return "coming soon";
        }

        /// <summary>
        /// Converts degrees minutes seconds axis value axis value to degrees
        /// </summary>
        /// <param name="p_iDegrees">degrees of the axis value</param>
        /// <param name="p_iMinutes">minutes of the axis value</param>
        /// <param name="p_dSeconds">seconds of the axis value</param>
        /// <returns>axis value in degrees</returns>
        public static double DegreesMinutesSecondsToDegrees(int p_iDegrees, int p_iMinutes, double p_dSeconds)
        {
            return 0.0;
        }

        /// <summary>
        /// Converts degrees minutes seconds axis value axis value to degrees
        /// </summary>
        /// <param name="p_sDegreesMinutesSecondsValue">degrees minutes seconds in a string format</param>
        /// <param name="p_bAxisType">latitude or longitude</param>
        /// <returns>double representing the position</returns>
        public static double DegreesMinutesSecondsToDegrees(string p_sDegreesMinutesSecondsValue)
        {
            return 0.0;
        }
        #endregion
    }
}
